#include "C3DPoint.h"
#include <iostream>
#include <math.h>

using namespace std;

//constructor
C3DPoint::C3DPoint()
{}
//deconstructor
C3DPoint::~C3DPoint()
{}

//operator overloading = 
C3DPoint& C3DPoint::operator = (const C3DPoint &p)
{
	_x = p._x;
	_y = p._y;
	_z = p._z;
	return *this;
}

//operator overloading +
C3DPoint C3DPoint::operator + (const C3DPoint &p)
{
	C3DPoint result;
	result.Set(_x+p._x, _y+p._y, _z+p._z);
	return result;
}

//operator overloading -
C3DPoint C3DPoint::operator - (const C3DPoint &p)
{
	C3DPoint result;
	result.Set(_x-p._x, _y-p._y, _z-p._z);
	return result;
}

//operator overloading *
C3DPoint C3DPoint::operator * (const double d)
{
	C3DPoint result;
	result.Set(_x*d, _y*d, _z*d);
	return result;
}

//set the point values
void C3DPoint::Set(const double x, const double y, const double z)
{
	_x = x;
	_y = y;
	_z = z;
}

//get the distance of 2 points
double C3DPoint::abs(const C3DPoint &p) const
{
	return sqrt(pow(_x-p._x,2) + pow(_y-p._y,2) + pow(_z-p._z,2));
}

//print out coordinate and poiint type
void C3DPoint::Print() const
{
	cout<<" "<<_x<<" "<<_y<<" "<<_z<<endl;
}

//Get values of points
double C3DPoint::x() const
{ return _x; }

double C3DPoint::y() const
{ return _y; }

double C3DPoint::z() const
{ return _z; }

